/*===============================================
Copyright (c): Technology Co.,Ltd. ALL rights reserved. 
                                                                 
  Create by: Lin
      Email:
       Date:
   Filename:
Description:
    Version:
Last Change:
                                                                 
=======================================*/
                                                                 
`ifndef MAC_AGENT_SV
`define MAC_AGENT_SV

`include "mac_driver.sv"
`include "mac_monitor.sv"
`include "mac_sequencer.sv"
`include "mac_seq_item.sv"

class mac_agent extends uvm_agent;

	mac_sequencer		ms_sequencer;
	mac_driver			m_driver;
	mac_monitor			m_monitor;

	`uvm_component_utils_begin(mac_agent)
		`uvm_field_enum(uvm_active_passive_enum, is_active, UVM_DEFAULT)
	`uvm_component_utils_end

	extern function new(string name, uvm_component parent);
	extern virtual function void build_phase(uvm_phase phase);
	extern virtual function void connect_phase(uvm_phase phase);

endclass: mac_agent

function mac_agent::new(string name, uvm_component parent);
	super.new(name, parent);
endfunction

function void mac_agent::build_phase(uvm_phase phase);
	super.build_phase(phase);

	m_monitor = mac_monitor::type_id::create("m_monitor", this);
	if(is_active == UVM_ACTIVE) begin
		m_driver = mac_driver::type_id::create("m_driver", this);
		ms_sequencer = mac_sequencer::type_id::create("ms_sequencer", this);
	end
endfunction

function void mac_agent::connect_phase(uvm_phase phase);
	super.connect_phase(phase);
	if(is_active == UVM_ACTIVE) begin
		m_driver.seq_item_port.connect(ms_sequencer.seq_item_export);
	end
endfunction

`endif
